﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Discovery;
using System.Xml;
using System.Xml.Linq;

namespace DirectoryService.ServiceModel.Discovery
{
    
    public class TransformXElement
    {

        public EndpointDiscoveryMetadata Translate(EndpointDiscoveryMetadata meta)
        {

            EndpointDiscoveryMetadata m = new EndpointDiscoveryMetadata()
            {
                Address = meta.Address,
                Version = meta.Version
            };

            foreach (XmlQualifiedName contract in meta.ContractTypeNames)
                m.ContractTypeNames.Add(contract);

            foreach (Uri uri in meta.ListenUris)
                m.ListenUris.Add(uri);

            foreach (Uri scope in meta.Scopes)
                m.Scopes.Add(scope);

            foreach (XElement ext in meta.Extensions)
                m.Extensions.Add(Translate(ext));

            AddExtension(m);

            return m;

        }

        private XElement Translate(XElement ext)
        {
            return ext;
        }

        private void AddExtension(EndpointDiscoveryMetadata meta)
        {
            
        }

    }

}
